<?php

class SlideModel extends Model{
	
	public $table='slide';
	
	public $auto=array(
		array('sthumb','_sthumb','method',2,3),
	);
	
	public function _sthumb(){
		
		$upload=new Upload();
		$file=$upload->upload();
		if($file){
			$img=new Image();
			$new_path=str_replace('.', '_sthumb.', $file[0]['path']);
			$thumb=$img->thumb($file[0]['path'],$new_path,2000,420,2);
			return $thumb;
		}else{
			if($thumbH=Q('post.sthumbH')) return $thumbH;
		}
	}
	
	public function get_all_data($where=null){
		
		return $this->where($where)->all();
	}
	
	public function add_data(){
		if(!$this->create()) return FALSE;
		
		return $this->add();
	}
	
	
	public function del_data($where=null){
		
		return $this->where($where)->delete();
	}
	
	public function get_one_data($where=null){
		
		return $this->where($where)->find();
	}
	
	public function edit_data($where=null){
		
		if(!$this->create()) return FALSE;
		return $this->where($where)->update();
	}
}











